package it.softphone.cmc.server.service;

import it.softphone.cmc.server.service.exception.CMCException;

public interface TenantService {

	interface Task<T> {
		
		T exec() throws Exception; 
	}
	
	String getCurrentTenant();

	void updateToSystemTenant();

	String getSystemTenant();
	
	void setTenant( String tenant );
	
	/**
	 * 
	 * @param tenant tenant name.
	 * @param task
	 * @return
	 * @throws CMCException
	 */
	<T> T execAsTenant( String tenant, Task<T> task ) throws CMCException;

	<T> T execAsSystemTenant( Task<T> task ) throws CMCException;
}
